//
//  FirstViewController.m
//  Demo1_UIViewController视图切换
//
//  Created by LZXuan on 15-5-9.
//  Copyright (c) 2015年 轩哥. All rights reserved.
//

#import "FirstViewController.h"
#import "MyControl.h"
#import "SecondViewController.h"


#define kScreenSize [UIScreen mainScreen].bounds.size

@interface FirstViewController ()
{
    SecondViewController *_svc ;
}
@end

@implementation FirstViewController
- (void)dealloc {
    [_svc release];
    [super dealloc];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    [self creatButton];
}
- (void)creatButton {
    //实例化一个按钮
    UIButton *button = [MyControl creatButtonWithFrame:CGRectMake(10, 30, kScreenSize.width-20, 30) target:self sel:@selector(btnClick:) tag:101 image:nil title:@"切换到下一级界面"];
    button.backgroundColor = [UIColor yellowColor];
    button.layer.masksToBounds = YES;
    button.layer.cornerRadius = 8;
    [self.view addSubview:button];
    
    _svc = [[SecondViewController alloc] init];
    
}
- (void)btnClick:(UIButton *)button {
    //把第二张的视图粘到第一张上面
    [self.view addSubview:_svc.view];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
